

export const AppEventName = {
    app_error: "app.error",
    app_init: "app.init",
    hashchange: "hashchange",
    app_route: 'app.route',
    app_dispatch: 'app.dispatch',
    app_pushView: 'app.pushView',
    app_removeView: 'app.removeView',
    app_popView: 'app.popView',

    app_loadRes: "app.loadRes",

}


export function isNull(obj: any) {
    return obj == undefined || obj == null || obj == '';
}
export type HttpResultCallback = (msg: string, data: any) => void;

export let OPPSITE: number[] = [-1, 1, 1, -1]
//默认朝右的角色对应的设置
export let OPPSITE_RIGHT: number[] = [1, -1, 1, -1]
//默认朝左的角色对应的设置
export let OPPSITE_LEFT: number[] = [1, -1, 1, -1]

export let OPPSITE_DIR: number[] = [1, 0, 3, 2]

/**
 * 方向枚举
 */
export enum DIR {
    LEFT,
    RIGHT,
    UP,
    DOWN,
    LEFT_UP,
    LEFT_DOWN,
    RIGHT_UP,
    RIGHT_DOWN,
    NONE,
}

export let MOVE_DIR: number[] = [-1, 1, 1, -1]
export let FACE_DIR: number[][] = [
    // [1, -1],
    // [-1, 1],
    [-1, 1],
    [1, -1],
]

/**
 * 等于
 * 大于等于
 * 小于等于
 * 大于
 * 小于
 * 不等于
 */
export enum CompareSign {
    EQUAL,
    MORE_EQUAL,
    LESS_EQUAL,
    MORE,
    LESS,
    NOT_EQUAL
}

export function gameCompare(value: number, sign: CompareSign, num: number): boolean {
    switch (sign) {
        case CompareSign.EQUAL:
            return value == num;
        case CompareSign.MORE_EQUAL:
            return value >= num;
        case CompareSign.MORE:
            return value > num;
        case CompareSign.LESS_EQUAL:
            return value <= num;
        case CompareSign.LESS:
            return value < num;
        case CompareSign.NOT_EQUAL:
            return value != num;
        default:
            return false;
    }
}

export enum OrientationType {
    Portrait,
    Landscape,
};



/**
 * id: 功能id
 * path：资源路径
 * control：控制器类名
 * model:模型类型
 * view：脚本类名
 * bundle:bundle名称
 * isToast:是否为toast提示
 */
export type FunctionItem = {
    id: number,
    control: string,
}



export let TYPE_LEN = 1000;

export function getItemType(id: number) {
    return Math.floor(id / TYPE_LEN)
}

export enum CoordinateType {
    LEFT_HAND,//左手坐标系
    RIGHT_HAND,//右手坐标系
}


export enum NumTypeEnum {
    num = 0,// 数量
    second = 1,// 秒
    minute = 2,// 分
    hour = 3,// 小时
    day = 4,// 天
    month = 5,// 月
    year = 6,// 年

}

/**
 * 未获得
 * 以获得
 * 可获得
 */
export enum ItemState {
    NOT_GET,
    GOT,
    CAN_GET,
    ON_GOING,
}